﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Manage/MasterPage.master" AutoEventWireup="true" CodeFile="ListArticles.aspx.cs" Inherits="ListArticles" %>
<%@ Register Src="~/Manage/CmsMessageBox.ascx" TagPrefix="cms" TagName="MessageBox" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            $('#SearchBar').width($('#Body table.List').width());

            
            $('#<%=DeleteArticle.ClientID %>').click(function () {
                //判断chkID选中的个数
                if (Cms_CkeckedCount('chkID') == 0) {
                    Cms_MessageBox("请选择将要删除的文章。");
                    return false;
                } else {
                    return Cms_Confirm('确认删除当前选中的文章吗？');
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="body" Runat="Server">
    <cms:MessageBox id="MessageBox" runat="server" />
    <asp:HiddenField ID="CurrentPage" runat="server" Value="1" />
    <div id="SearchBar">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td align="right">所属栏目：</td>
                <td><asp:DropDownList ID="Topics" runat="server" Width="100px" AutoPostBack="True" 
                        onselectedindexchanged="Topics_SelectedIndexChanged"></asp:DropDownList></td>
                
                <%if(Toolkit.HasPower(Powers.ArticleManager)){ %>
                    <td><asp:HyperLink ID="AddArticle" runat="server" NavigateUrl="~/Manage/EditArticle.aspx" SkinID="AddLink">增加文章</asp:HyperLink></td>
                <%} %>    
                
                <td><asp:LinkButton ID="DeleteArticle" runat="server" Text="删除文章" 
                            SkinID="DeleteButton" onclick="DeleteArticle_Click"></asp:LinkButton></td>
                <td><asp:LinkButton ID="StaticArticles" runat="server" Text="静态化文章" 
                            SkinID="StaticButton" onclick="StaticArticles_Click"></asp:LinkButton></td>
                

                <td><asp:TextBox ID="SearchCondition" runat="server" SkinID="SearchBox" /><asp:HiddenField ID="SearchConditionHidden" runat="server" /></td>
                <td><asp:Button ID="Search" runat="server" Text="查询" 
                        onclick="Search_Click"/></td>
            </tr>
        </table>
    </div>
    <div style="clear: both">
        <asp:Repeater ID="ArticlesView" runat="server">
            <HeaderTemplate>
                <table class="List" cellspacing="1">
                    <tr class="header">
                        <th style="width:60px">操作</th>
                        <th style="width:250px">文章标题</th>
                        <th style="width:150px">子标题</th>
                        <th style="width:70px">所属栏目</th>
                        <th style="width:70px">发布人</th>
                        <th style="width:120px">发布时间</th>
                    </tr>
            </HeaderTemplate>
            <AlternatingItemTemplate>
                <tr class="even">
                    <td align="center" style="width: 60px">
                        <input type="checkbox" name="chkID" value='<%#Eval("ID") %>'/>
                        <asp:HyperLink runat="server" NavigateUrl='<%#"~/Html/" + Eval("Url") %>' Target="_blank">
                            <asp:Image ID="Preiew" runat="server" SkinID="ArticleView"/>
                        </asp:HyperLink>
                    </td>
                    <td align="center" style="width: 250px">
                        <%if(Toolkit.HasPower(Powers.ArticleVerifier)){ %>
                            <asp:HyperLink ID="HyperLink2" runat="server" 
                                NavigateUrl='<%#"~/Html/" + Eval("Url") %>' Target="_blank"><%#Eval("Title") %></asp:HyperLink>
                        <%}else{ %>    
                            <asp:HyperLink ID="EditArticle" runat="server" 
                                NavigateUrl='<%#"~/Manage/EditArticle.aspx?aid=" + Eval("ID") %>'><%#Eval("Title") %></asp:HyperLink>
                        <%} %>
                    </td>
                    <td align="center" style="width: 150px"><%#Eval("Subtitle") %></td>
                    <td align="center" style="width: 70px"><%#Eval("TopicName") %></td>
                    <td align="center" style="width: 70px"><%#Eval("CreatorName")==null?"佚名":Eval("CreatorName") %></td>
                    <td align="center" style="width: 120px"><%#string.Format("{0:yyyy-MM-dd HH:mm}", Eval("Published")) %></td>
                </tr>
            </AlternatingItemTemplate>
            <ItemTemplate>
                <tr class="odd">
                    <td align="center" style="width: 60px">
                        <input type="checkbox" name="chkID" value='<%#Eval("ID") %>' />
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"~/Html/" + Eval("Url") %>' Target="_blank">
                            <asp:Image ID="Preiew" runat="server" SkinID="ArticleView"/>
                        </asp:HyperLink>
                    </td>
                    <td align="center" style="width: 250px">
                        <%if(Toolkit.HasPower(Powers.ArticleVerifier)){ %>
                            <asp:HyperLink ID="HyperLink2" runat="server" 
                                NavigateUrl='<%#"~/Html/" + Eval("Url") %>' Target="_blank"><%#Eval("Title") %></asp:HyperLink>
                        <%}else{ %>    
                            <asp:HyperLink ID="EditArticle" runat="server" 
                                NavigateUrl='<%#"~/Manage/EditArticle.aspx?aid=" + Eval("ID") %>'><%#Eval("Title") %></asp:HyperLink>
                        <%} %>
                    </td>
                    <td align="center" style="width: 150px"><%#Eval("Subtitle") %></td>
                    <td align="center" style="width: 70px"><%#Eval("TopicName") %></td>
                    <td align="center" style="width: 70px"><%#Eval("CreatorName")==null?"佚名":Eval("CreatorName") %></td>
                    <td align="center" style="width: 120px"><%#string.Format("{0:yyyy-MM-dd HH:mm}", Eval("Published")) %></td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                <tr class="Footer">
                    <td colspan="7" align="center">
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>共 <%=pds.DataSourceCount %> 条记录</td>
                                <td><asp:LinkButton ID="FirstButton" runat="server" SkinID="FirstButton" OnCommand="ChangePage" CommandArgument="F">&nbsp;</asp:LinkButton></td>
                                <td><asp:LinkButton ID="PreviousButton" runat="server" SkinID="PreviousButton" OnCommand="ChangePage" CommandArgument="P">&nbsp;</asp:LinkButton></td>
                                <td>第 <%=pds.CurrentPageIndex+1 %> 页 / 共 <%=pds.PageCount %> 页</td>
                                <td><asp:LinkButton ID="NextButton" runat="server" SkinID="NextButton" OnCommand="ChangePage" CommandArgument="N">&nbsp;</asp:LinkButton></td>
                                <td><asp:LinkButton ID="LastButton" runat="server" SkinID="LastButton" OnCommand="ChangePage" CommandArgument="L">&nbsp;</asp:LinkButton></td>
                                <td><asp:TextBox ID="GotoPage" runat="server" Width="30px"></asp:TextBox></td>
                                <td><asp:LinkButton ID="GotoButton" runat="server" SkinID="GotoButton" OnCommand="ChangePage" CommandArgument="G">&nbsp;</asp:LinkButton></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
</asp:Content>

